package com.mytest.leetcode.middle;

import com.mytest.leetcode.SolBase;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;

/**
 * Created by shixi  on 2019/6/24
 */
@Slf4j
public class Solution470 extends SolBase {

    public static void main(String[] args) {
        Solution470 solution = new Solution470();
        log.info("{}",solution.rand10());
    }


    public int rand10() {
        while(true) {
            int num = (rand7() - 1) * 7 + rand7(); // 等概率生成[1,49]范围的随机数
            if(num <= 40) return num % 10 + 1; // 拒绝采样，并返回[1,10]范围的随机数
        }
    }
}

